<?php

namespace app\api\controller;

use app\admin\model\Banner;
use app\admin\model\Question;
use app\common\controller\Api;

/**
 * 首页接口
 */
class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 轮播
     *
     */
    public function banner()
    {
        $banner = Banner::where(['status'=>'normal'])->order('weigh desc')->select();

        $this->success('请求成功',$banner);
    }

    public function question()
    {
        $question = Question::order('weigh desc')->select();

        $this->success('请求成功',$question);
    }

    public function questionInfo()
    {
        $id = input('id',0);

        $question = Question::get($id);

        $this->success('请求成功',$question);
    }

    //配置
    public function config()
    {
        $data = [
            'name'=>\app\common\model\Config::get(['name'=>'name'])->value,
            'logo'=>\app\common\model\Config::get(['name'=>'logo'])->value,
            'kefu_qrcode'=>\app\common\model\Config::get(['name'=>'kefu_qrcode'])->value,
            'kefu_mobile'=>\app\common\model\Config::get(['name'=>'kefu_mobile'])->value,
            'process'=>json_decode(\app\common\model\Config::get(['name'=>'process'])->value,true),
        ];
        $this->success('请求成功',$data);
    }

    //协议配置
    public function agreementConfig()
    {
        $data = [
            'aboutus'=>\app\common\model\Config::get(['name'=>'aboutus'])->value,
            'joinus'=>\app\common\model\Config::get(['name'=>'joinus'])->value,
            'privacy_agreement'=>\app\common\model\Config::get(['name'=>'privacy_agreement'])->value,
            'user_agreement'=>\app\common\model\Config::get(['name'=>'user_agreement'])->value,
        ];
        $this->success('请求成功',$data);
    }

    //收款配置
    public function collectionConfig()
    {
        $data = [
            'ali_account'=>\app\common\model\Config::get(['name'=>'ali_account'])->value,
            'ali_account_name'=>\app\common\model\Config::get(['name'=>'ali_account_name'])->value,
            'account_name'=>\app\common\model\Config::get(['name'=>'account_name'])->value,
            'bank_card'=>\app\common\model\Config::get(['name'=>'bank_card'])->value,
            'opening_bank'=>\app\common\model\Config::get(['name'=>'opening_bank'])->value,
        ];
        $this->success('请求成功',$data);
    }

    public function isShow()
    {

        $this->success('请求成功',1);
    }
}


